<template>
  <div class="box">
    <div class="title">
      <p>年龄比例</p>
      <img src="../images/dataScreen-title.png" alt="" />
    </div>

    <div class="echarts" ref="echart"></div>
  </div>
</template>

<script setup lang="ts">
import * as echarts from "echarts";
import "echarts-liquidfill";
import { ref, onMounted } from "vue";

let echart = ref();
onMounted(() => {
  let mycharts = echarts.init(echart.value);
    mycharts.setOption({
      tooltip: {
        trigger: "item",
      },
      legend: {
        top: 10,

        right: "right",
        orient: "vertical",
        textStyle: {
          color: "#fff",
        },
      },
      series: [
        {
          name: "Access From",
          type: "pie",
          radius: ["40%", "70%"],
          avoidLabelOverlap: false,
          itemStyle: {
            borderRadius: 10,
            borderColor: "#fff",
            borderWidth: 2,
          },
          label: {
            show: true,
            position: "inside",
            color:'#fff',
            fontSize:12
          },
          // emphasis: {
          //   label: {
          //     show: true,
          //     fontSize: 40,
          //     fontWeight: "bold",
          //   },
          // },
          labelLine: {
            show: false,
          },
          data: [
            { value: 1048, name: "Search Engine" },
            { value: 735, name: "Direct" },
            { value: 580, name: "Email" },
            { value: 484, name: "Union Ads" },
            { value: 300, name: "Video Ads" },
          ],
        },
      ],
      grid: {
        left: 0,
        right: 0,
        bottom: 0,
        top: 0,
      },
    });
});
</script>

<style scoped lang="scss">
.box {
  width: 100%;
  height: 100%;
  background: url(../images/dataScreen-main-cb.png) no-repeat;
  background-size: 100% 100%;
}
.title {
  color: white;
  font-size: 20px;
}

.echarts {
  width: 100%;
  height: 240px;
}
</style>
